package com.ycy.lucene.search;

import com.ycy.lucene.index.IndexReadDemo;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.MultiPhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.wltea.analyzer.lucene.IKAnalyzer6x;

public class MultiQuery {

  public static void main(String[] args) {
    // TODO 待研究
    MultiPhraseQuery.Builder builder = new MultiPhraseQuery.Builder();
//    builder.add(new Term("name","密室"));
//    builder.add(new Term[]{new Term("name","八"),new Term("name","白")});
//    builder.add(new Term("name","店"));

    MultiFieldQueryParser multiFieldQueryParser = new MultiFieldQueryParser(new String[]{"name", "address"}, new IKAnalyzer6x());
    try {
      Query query = multiFieldQueryParser.parse("普安");

      IndexReadDemo.search(query, 10, Sort.RELEVANCE);

    } catch (ParseException e) {
      e.printStackTrace();
    }

  }

}
